package com.study.dao.impl;

import com.study.dao.IRedisDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

@Repository
public class RedisDaoImpl implements IRedisDao{
    @Autowired
    private JedisPool jedisPool;
    //private Jedis jedis = jedisPool.getResource();

    public void set(String key,String value){
        Jedis jedis = jedisPool.getResource();
        jedis.set(key,value);
        jedis.close();
    }

    public String get(String name) {
        Jedis jedis = jedisPool.getResource();
        String s = jedis.get(name);
        jedis.close();
        return s;
    }
}
